package com.wn.sddfp.common.exception;


import com.wn.sddfp.common.result.enums.IErrorCode;
import com.wn.sddfp.common.result.enums.impl.BusinessCode;

/**
 * 自定义的断言类
 */
public class Assert {

    public static void error(String message) {
        throw new BusinessException(message);
    }
    public static void error(IErrorCode errorCode) {
        if (errorCode == null){
            //如果为null 需要设置
            throw new BusinessException(BusinessCode.FAILED);
        }
        throw new BusinessException(errorCode);
    }

    public static void error(Object obj,String message) {
        if (obj == null) {
            throw new BusinessException(message);
        }
    }

    public static void error(Object obj,IErrorCode errorCode) {
        if (obj == null) {
            throw new BusinessException(errorCode);
        }
    }

    public static void error(boolean flag,IErrorCode errorCode) {
        if (flag) {
            throw new BusinessException(errorCode);
        }
    }
}
